package com.lyshop.jinxiang.view;

import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.lyshop.jinxiang.R;
import com.lyshop.jinxiang.utils.DataUtils;
import com.lyshop.jinxiang.utils.Utils;


public class FollowOrderExplainDialog extends MyDialog implements View.OnClickListener {

    private View rootView;
    private View view_top;
    private TextView tv_explain;
    private TextView tv_desc;

    private DialogListener mListener;

    public FollowOrderExplainDialog(Context context) {
        this(context, true, Gravity.BOTTOM);
    }

    public FollowOrderExplainDialog(Context context, boolean isCancelAble, int gravity) {
        super(context, isCancelAble, gravity);
        Window w = this.getWindow();
        if (w != null) {
            w.setWindowAnimations(R.style.dialogTranslateAnim);
        }
        rootView = LayoutInflater.from(context).inflate(R.layout.dialog_follow_explain, null);
        setContentView(rootView);

        view_top = rootView.findViewById(R.id.view_top);
        tv_explain = rootView.findViewById(R.id.tv_explain);
        tv_desc = rootView.findViewById(R.id.tv_desc);

        String desc = "注：因原料价格波动较快，<font color=\"#E55C5C\">跟单订购点位均以原料价格实时波动点为准。</font>";
        Utils.setHtmlText(tv_desc, desc);
        setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                DataUtils.setBooleanSPByTag(mContext, DataUtils.SP_FOLLOW_ORDER_EXPLAIN, true);
            }
        });
        view_top.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.view_top:
                if (isCancelAble) {
                    dismiss();
                }
                break;
        }
    }

    public interface DialogListener {
        void onConfirm();

        void onCancel();
    }

}

